package requests

import (
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type RoomRequest struct {
	Rule string `json:"rule" valid:"rule"`
	Num  int    `json:"num" valid:"num"`
}

func RoomValidate(data interface{}, c *gin.Context) map[string][]string {
	// 自定义验证规则
	rules := govalidator.MapData{
		"rule": []string{"required"},
		"num":  []string{"required"},
	}

	// 自定义验证出错时的提示
	messages := govalidator.MapData{
		"rule": []string{
			"required:邮规则必须填写",
		},
		"num": []string{
			"required:局数必须填写",
		},
	}
	return validate(data, rules, messages)
}
